/**
 * @author wangshihan
 * @description 打包
 */
import { execa } from 'execa';
import { getPkgs } from './utils.js';

const pkgs = getPkgs();

const build = async pkg => {
  await execa('rollup', ['-c', '--environment', `TARGET:${pkg}`], { stdio: 'inherit' });
};

const runParallel = (targets, buildFn) => {
  const res = [];
  for (const target of targets) {
    res.push(buildFn(target));
  }
  return Promise.all(res);
};

runParallel(pkgs, build);
